package com.starry.module.system.core.member.controller.app;

import com.starry.core.common.domain.R;
import com.starry.core.web.core.controller.BaseController;
import com.starry.module.system.api.member.domain.qo.MemberUserUpdateByLogin;
import com.starry.module.system.api.member.domain.vo.MemberUserLoginInfo;
import com.starry.module.system.core.member.service.AppMemberUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

/**
 * App-会员用户
 *
 * @author xiaoke
 */
@Tag(name = "App-会员用户")
@RestController
@RequestMapping("/system/memberUser")
public class AppMemberUserController extends BaseController {

    private final AppMemberUserService memberUserService;

    public AppMemberUserController(AppMemberUserService memberUserService) {
        this.memberUserService = memberUserService;
    }

    /**
     * 根据登录信息查询会员用户
     *
     * @return {@link MemberUserLoginInfo}
     */
    @Operation(summary = "根据登录信息查询会员用户")
    @GetMapping("memberUserByLoginInfo")
    public R<MemberUserLoginInfo> memberUserByLoginInfo() {
        return success(memberUserService.getByLoginInfo());
    }

    /**
     * 更新登录用户信息
     *
     * @param memberUserLoginInfo {@link MemberUserUpdateByLogin}
     * @return {@link R<Void>}
     */
    @Operation(summary = "更新登录用户信息")
    @PostMapping("updateByLoginInfo")
    public R<Void> updateByLoginInfo(@RequestBody MemberUserUpdateByLogin memberUserLoginInfo) {
        memberUserService.updateByLoginInfo(memberUserLoginInfo);
        return success();
    }
}
